/******************************************************************************

		Filename (class)        :       Logger.h (Logger)
		Author                  :       Kuba Sejdak
		Last modification       :       29.03.2011
		Architecture			:		All
		Description             :       Simple class that provides interface to
		manage logging. Includes file handling and appending date and time info.

******************************************************************************/

#ifndef LOGGER_H
#define LOGGER_H

#include <QtGui>

QString getDateStr();
QString getTimeStr();

enum LogState {
	DONE,
	OPEN_FILE_ERROR,
	WRITE_FILE_ERROR,
	CLOSE_FILE_ERROR,
	FILE_NOT_SET
};

class Logger {
	int maxFileSize;
	QString fileName;
	QString errorPreffix;
	QFile *file;

	void checkFileSize();
	void clearFile();

public:
	Logger();
	Logger(QString file);

	void setFileName(QString file);
	void setFileNameDialog();
	void setMaxFileSize(int size);
	void setErrorPreffix(QString preffix);
	LogState writeLog(QString message);
	LogState writeErrorLog(QString message);
	QString getLog(QString message);
	QString getErrorLog(QString message);
};

#endif // LOGGER_H
